import { urlDao } from "~/dao";
import { useRequestText } from "~/lib/http";

import { ClientCacheService } from "./components/ClientCache";
import { ClientInstanceService } from "./components/ClientInstance";
import { ClientDocService } from "./components/ClientDoc";
import { ClientIndexService } from "./components/ClientIndex";
import { ClientSearchService } from "./components/ClientSearch";

export const clientCacheService = ClientCacheService({
  adapter: (c) => {
    return useRequestText(c.url!, c);
  },
  getUrlById: async (id: string) => {
    return urlDao.selectById(id);
  }
});

export const clientInstanceService = ClientInstanceService(clientCacheService);
export const clientDocService = ClientDocService(clientCacheService);
export const clientIndexService = ClientIndexService(clientCacheService);
export const clientSearchService = ClientSearchService(clientCacheService);
